#include<cstdio> 
using namespace std;
const int maxn=1001;

int n;
int cnt[maxn];
int child[maxn][maxn];
int unlock[maxn];
int points;
int threshold[maxn],bonus[maxn];

bool find(){
	int target=-1;
	for(int i=1;i<=n;i++){
		// (1),(2)  
		if(unlock[i]==0&&points>=threshold[i]){
			target=i;
			break;
		}
	}
	if(target==-1) return false;
	unlock[target]=-1;
	//(3)
	--cnt[target];
	for(int i=0;i<cnt[target];++i)
	//(4)
	unlock[child[target][i]]=0;
	return true;	
}
int main(){
	scanf("%d%d",&n,&points);
	for(int i=1;i<=n;++i){
		cnt[i]=0;
		scanf("%d%d",&threshold[i],&bonus[i]);
	}
	for(int i=1;i<=n;++i){
		int m;
		scanf("%d",&m);
		unlock[i]=0;
		for(int j=0;j<m;j++){
			int fa;
			scanf("%d",&fa);
			child[fa][cnt[fa]]=1;
			++cnt[fa];
		}
	}
	int ans=0;
	while(find()){
		++ans;		
	}
	printf("%d\n",ans);
	return 0;
}
